package com.yeyks.hotel.vo;

import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yeyks.hotel.dal.domain.RoomInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class HotelInfoHotelSearchHotelInfoRoomInfoVo extends RoomInfo {

    @ApiModelProperty("最低售价")
    private Integer salePrice;
    @ApiModelProperty("实付价")
    private Integer payPrice;
    @ApiModelProperty("房间数")
    private Integer roomCount;

    //图片url
    public List<String> getImages() {
        try {
            return JSONUtil.parseObj(getExtraInfo()).getJSONArray("imgUrlList").toList(String.class);
        } catch (Exception e) {
            return new ArrayList<>();
        }
    }

    public Integer getPayPrice() {
        Integer minPrice = this.salePrice;
        if (Objects.nonNull(minPrice)) {
            return Double.valueOf(Math.ceil(minPrice / 200) * 100).intValue();
        }
        return null;
    }

}
